BUG:371124 Fix a crash when using two windows.
If there's an if(tool){...} else {} then all use of tool needs to be in that if block.