Moved some functions to tools