Some changes to linear solver.

I changed some parts of linear solver, so it's more flexible for
accepting boundary conditions, especially internal boundary conditions.