Moved Tool class to scripts/tool.js and fixed group selection bug