Fix bug where topic counter was not being incremented/decremented correctly