Refactor all the stuff