Improve interoperation between serialization and DI