Merge "Fixing bad refactoring of orientation calculation."