Converted rest of the code to use contracts.