Fixed loops after PHP 5.2 adaptaion.