Add support for preview and clean up the dirs