Added metadata handling to elements.

I think everything's ready to define the trees.