Refactor a bit.