more libs to run toools
first refactoring and  class cast fixing