fixed missing metadata and DB cleanup