Fix off-by-one errors in session/tunnel initialisation and sessiont <-> sessionidt functions.
Use session[s].opened consistently when checking for in-use sessions (rather than session[s].tunnel).
Use <= cluster_highest_sessionid rather than < MAXSESSION in a couple of loops.