Fixing bug with serialization