reorder some stuff for better readability
begin reworking tool and history logic
rework some history logic