Leak fix + added flexibility in Solver

Now we can switch from direct to iterative solver while keeping
Cholesky factorization. This is done with future sparse inverse
preconditioner in mind.