Refactor code a bit.