Refactoring, preparing to support `metadata.json`

See #7