Consolidated deserializer type cache

This was from a previous bug fix branch, but you manually merged, and didn't grab this bit as it wasn't required for the fix. Anyway, just a style thing. Less duplication. Easier to maintain. Not that the deserializer side is particularly messy, but this same style could be replicated for the Serializer side, where it is messy. The deserializer side was done first as it was easier for a proof of concept.