Clean up some code
Fix CORS XHR