fixed bug with setting root doc which would fail if the document class isn't on the top line