Minor cleanup and reformatting

Hi Phan,

I was playing around with fantomas last night and saw a few places where the code could be simplified. I made the changes and also folded some of the really long match lines onto multiple lines to make the code easier to browse.

Cheers,
Jack