Topic/tree checking

Two new commits over #113, which make tree checkers typecheck things.