Set the framerate limit and fixed some timing bugs.