Some performance imporivements
Fix bug in C++/haskell interface of matrix solving.