some new features, plus type refactoring start