code cleanup and doc tweaks