fixing glitches and improving comments on code