some code contracts fixes