Improved log file handling.