small changes to Bai Ng replication
refactor some things into util.jl
major refactoring

Bai Ng (2002) made no sense here for some reason. One of the big things
was that for some reason which I dont understand yet the inv(loadings')
is not the same as loadings although loadings is orthogonal.
added a flatten function which is not used at the moment