bugfix: empty elements at end of buffer

this triggered a parsing error.
also, empty elements are now emitted as empty