Dedupe view/applications

There were five copies of some parts of the code!