Fixing bugs where failed sends crashes the gateway.
Merge pull request #4 from irjudson/master

Fixing bugs where failed sends crashes the gateway.