optimize key serialization