Imported changes from 2ab0d142a5.
Scope code to current ToolSet.