Rewrite for 1.0

Overhauled all the code from the ground up.