Type variables

3 separate commits here that will be easier to view in isolation