Proper count of trailing non-zero values, instead of stopping to serialize key values when first 0 is encountered. Fixes #1.