Bugfix, refactoring orthogonality calculations