Start some much needed refactoring