Fixed compiler warning and possible infinite loop.