Bug fix for reset counter after restart

The fix now is provisional. We'll need to add code to store the last
given out ID, and check for that on restart.