Start refactoring and simplifying code