The current is quite dirty and could do with some more type checking. It's also a step towards using libmatroska.