Merge "Added check to make orientation calculations more robust" into gingerbread