Renamed and modified context tree code