Finished refactor. Now getting functional tests to work.