General code cleanup and doc update