Modified thread loop.