Fixing bugs in solver