code cleanup and commentary