Logging improvement, adding purge logs option