add docstrings, change random to Random for secure removal of files