Updated docs and some code cleanup.