typechecker: reverted to working version from July 5th

Version before changes made in da014