Make HashMap use toHash() if available instead of TypeInfo.getHash().
Make MemoryStream dynamically, optionally growable until it reaches its final capacity.