Refactor into pieces that make sense.