Simplify metadata parsing code