Moved metadata extraction to separate class