A bit more of refactor done and sparse matrix added