added fixes for MQTT.
Merge pull request #32 from abeykoon/fix_MQTT_functionality

added fixes for MQTT subscriptions and some refactoring.