Some improvements. Still trying to get an efficient way to solve Ax=B