Refactor to put everything in methods where it should be.