Unnecessary casts have been removed and all tests have been matched to the template.