minor code cleanup and a few comments