Typechecking and improvements