Refactored entire class that handles the encoding methods for Ancient type HMessage instances.