lots of changes necessary for better session support in server