At cycle detector, prevent NoSuchElementException at the main loop.

This could happen after currentBranch value is updated (line 102) to a non-null value that contains an empty stack. Also:
replace condition in loop by a while(true), thus making the loop faster (we will have to check if currentBranch is null after
updating it at line 102 anyway.
Remove ControllerHolder