I've rewritten the toolbutton identification algorithm. Hopefully the current implementation is faster and easier to read.
dfbdcb9