remove document factory, move document creation stuff into preprocessor