Adding in cross origin support and fixing up some code