added support for the TypeWrapper.asType method and many other small refactorings