#20 some refactoring, ready to implement metadata reader.