Rewrite

Not ready to merge, but this is the branch the rewrite will happen in.