Fix count serialization

Fixes #1015 
Ok, I can fix it.