Optimize sorting

Now only sorts once per mappings.
Simplify preRender function.

Also removes useless crap that didn't even work.