Add support for CORS / XHR

This is ready to be looked over now.
We want to use smaller try/catch blocks and call functions from within them.

See http://blog.dubbelboer.com/2012/04/16/node-try-catch.html and http://jsperf.com/try-catch-performance-overhead and http://jsperf.com/try-catch-002