some refactoring and tweaks so that arrows detect jumps and the right arrow stops at the end.