Clean up code. Update tests.