Cleaned up code

ghc-mod made several stylistic suggestions, I followed them
A few other modifications that made the whole thing more readable