Split out logic into separate controllers and views.