Separate views from logic.

As discussed in #671