Fixes large document crash for #261.