Further improvements to proof search.

Also added a proof search test case.