Reset gateway search

Reset the gateway search after successfully adding a gateway.

The first two commits belong to #695, and should disappear once it gets merged.

Fixes part of #692.