TypeReference constructor for serialising, and serialisation tests.
Better generic support and more JavaDoc comments