Refactors set up from main