Improved way filename is retreived. Improved way file paths are created. Improved logging.