Flexible Session handling

fixes #507