Finishes the rewrite. Compiles and passes the first (very easy) test sample.