Fix producing out-of-bounds hex constants. Also cleanup.