Finished Rewrite, Formatting

Finished writing the code, now awaiting tests.