More fiddling with various aspects of encoding/decoding of numerics.

More tests pass, but there are still some issues that I am unsure of.