Added functionality to serialize objects