Bug fixes for corner cases in IR implementation