Clean up code, refactor into functions.
Add v1 -> v0 test.