Alter code to remove type erasure warnings