added file cleanup to main loop and base cleanup function to tools.py. need to finish.