Corrected small bug in index array update
Now using self balancing binary search trees as indexes