I just switched one of the major loops from a while (without wait) to a for loop. It did not make any noticeable impact on frame rate.