Rewrite for speed.
Merge pull request #1 from mdx-dev/feature/speed

Rewrite for speed.