rework tunnel logic

Refactoring to make things a bit saner and easier to debug.