Refactor a lot.