Session handling and exception handling