Brought the remaining fns out of main, better frame rate limiter