Add safeguard to deserialization