Refactoring of identity-associated code
Moved Identity class to a separate file