Added a lot of CRUFT to make CORS work, cleanup later