add metadata, and cleanup