added gateway support

A gateway can be specified in config.cfg within a [connection] section.

example:

[connection]
gateway = hub.example.com
added documentation and simplified code
fixed typo
Merge pull request #171 from hojerst/master

added gateway support