Started refactoring code.