code cleanup with internal comments