Moved functions to tools.