Added 'save' function and a log file.