fixed some bugs with the tools depending on global state