Fixed messaging.cpp bug where counter is not correctly stored.