Added context tree code