Add some Haddock documentation and tidyup.