Contract bugfixes