Lots of documentation and code style fixes