Fix bug with message counter