Fixed bugs in solver