Changed extraction of document text to use proper synchronization mechanism.