debug prints, first working call on matrices X but not yet fully correct
minor fixes and new asserts for numerical stability