Fixed a few issues with gateway