Use sleep to maintain framerate and calculate microseconds correctly