switched mqtt client implementation, and added better mqtt connection handling