Get better at handling rowspacings

At least, parse and generate the correct output. Seems to be some
memory leak introduced here, as the tests flap.