First attempts at splitting code up into smaller methods.
Merge pull request #5 from kaspernj/kj/code_climate_optimizations

CodeClimate optimizations