Massive refactoring to make rubocop happy!