Bug fix for serializing an object