Refactoring. Moving generic code to separated modules.