Fix TextDocumentParser to play nice with threading