BUG-2825: move code around and improve hex lookup