Fixed bug in get_depth_from_index where the index counter was not being increased.