Tidy up the code
Minor bug fixes & documentation updates