First pass at the real typechecker!