Rewrite it from scratch

Delete everything and rewrite it from scratch.