Fixed session index allocation
Oops, wrong algorithm
Oops; now it works