Type system: some refactoring and simplifications