Make initial _nav_data generation code more readable and use None instead of -1 to indicate no next step (this caused bugs)