Fixed main loop CPU full usage problem.