add all types support, plus small refactoring