Refactor.

This is now complete.