MongoDb backend to store firmware

support for ethernet and serial gateway (serial untested)
getting rid of global variables and cleaning up a lot of code