Fixed bug that was losing messages when reconnecting.