Documentation overhaul plus some code style fixes