First implementation of typechecker