Fixing CORS support, adding JSON headers to ajax responses