fix the "one frame ahead bug". closes #1.