Refactor view code.