JIT: refactoring some code in the forward search.