Cleaned/changed the code to match toolgear.lua