Fixed problems with CodeContracts definitions.

Also, replaced some code contracts calls with calls to helper methods.