Cleanup and comment code