Added error handling to sessions.