more transposeInnerProduct optimisation: convert to Matrix where helpful
misc tidying
refactoring