Refactor view rendering into a class/library.