moved some code from TypeChecker to Types and Utils