scoped type variables removed + some refactoring