Added code to check that function return values match declared type.