Refactor to put everything in a class with methods.