Started code refactoring