Bugfixes in document manipulation.