Neatened up whims mqtt code