Improved comments (Haddock).
Minor changes.
Added thw functions to make testing easier.