Error handling and options.cookieKey fix