Complete rewrite (unfinished)

Pushing what I have so far.
Mostly working but a little horrible in places. Also some serious ninja
comments going on.