More elegantly fixed the IR bug

where the IR would take negative values.  I just convert it to unsigned by
bitwise ANDing it with 16 ones.
Removed magic number 16 from bugfix code