Type refactoring and more documentation