Fixing serialization to work properly