minor typo-level bugfixes
add useful errors for the decode-failure case
guard against infinite loop on negative counts