Fix scheduling the next frame at the right time