cleanup mqtt code, fix double messages