metadata cleaning up and refactoring