partial conversion from HirschC