Did some basic refactoring