Merge pull request #2831 from Delja/contract_fix_error