contract corrections and logic fixes