beginning to refactor metadata.js ... not done