Commit Rabu

Fix:
-gateway memory leak
-gateway sql code refining

Unfixed:
-event snapshot method
-send payload to remote xbee methode
-gateway surviving generation keep increasing