Fixed issue with AddContract for partially defined types. Minor refactorings.

Related Work Items: #9