Lots of documentation and fixes