Bugfix. Length using bytes with the value 0 failing.

(Ex: 256 0x01 0x00).  Refactor the marshalLength code.