Refactor Tool detection to remove duplicate code and simplify subclasses