Major refactoring of headtracking.