Rework session handler a little