Fixed bugs discovered by findbugs.

Mostly we compared two objects of different type using equals.  Additionally, some strange pieces of code were detected in the proof tracker and remove/rewritten.