Refactor metadata class and put in its own file.