cleanup mqtt code