some cleanup and more docs
only toggle resultState when last pixel has been reached