Major rewrite.

This breaks just about everything from v0.8