Fixed rest infinite loop bug.