Incrementally increasing type-safety with a ClassKeys type

One of the bigger bugs found was due to the use of the wrong map - a
type alias for ClassKeys prevents this from happening.