Added functions for hex conversions
some cleanup.
more refactoring.
Merge some hexadecimal encoding/decoding cleanup.