Bug fix in OrthogonalState and refactoring