Fix segfault caused by MQTT handling