Added several code contracts.