Refactor string functions, fix many defects.

Use ToHex without the prefix, then you can drop all the other fiddling. You're also setting the width twice.