Fixed high cpu usage in some specific cases