Bugfixes for gateway stuff.