added additional logging, and use a timer for gateway discovery (see issues #1
and #4)