some code cleanup and documentation update