XHR support and some other fixes