Refactored out some repeated code
Renamed a couple of methods and variables