Serialisation of generic classes