Support for CORS and bugfix for encoding