Avoid getting stuck in infite loop (Issue #117).