Lots of bug fixes; add logging. Re-do install script.
A bit of tidying up. Improved documentation.