final round of code cleanup and comments