Fixed possible NPE during serialization