some tools refactoring and housecleaning