Fixed the xss stuff to work with gateways