Refactor to split things up a bit.