added CORS support, and some debugging