Bug fix: making the reader type is checked against, not the writer type,
when confirming equality.

Adding a cache for type resolution to prevent the same HashSet from
being constructed every time.