added various tools and some refactoring