Backport mostly commentary and formatting from TIREM_Cxx.