Added export feature and logging.