Bugfixes and rewrite parts of code
Merge pull request #28 from Damme/MQTTGateway

Bugfixes and rewrite parts of code