Complete rewrite to make everything a little less bad, support bulb and gateway disconnects and reconnects, and make everything a little more OOP