code cleanup and documentation update