Fix serialization when using distributed cache.