Refactored long method `InMemoryClassToIdentityMapper::register()`