Add subclass matching to serializer field mapping.

First attempt at #1809.
Updated indentation slightly for bettter clarity.