Small fixes to orientation code