Redid packing/unpacking to be optimized. Fixed bugs.

The old system required at least 8 bytes for any given field. The
new system handles each case (each possible number of bytes from
1 through 9) individually. There's a ton of code reuse, but the
benefit is a large performance increase (generally ~2x) since
we don't need to allocate any temporary buffers. Additionally,
since many control flow branches are special-cased and get their
own closure, the resultant code involves no branching (though
there remains the possibility of bit-shifting unnecessarily
if the shift operand is 0).

Additionally, the old system had previously unnoticed bugs which
have been fixed.