cleanup and comment code