Some code cleanup and comments #1765