Tidied up haskell code

Applied HLint to improve code quality, documented a bit, improved
formatting