Fix infinite restart loop bug.