Performance fixes.

- Avoid looking up the document from each element. This requires a
  context switch from Ruby to C.
- Don't allow rules to be reused across multiple documents. We don't
  need it, and it slows things down by requiring hash lookups.