Move unlock view to separate module
Refactor app setup function

Split app setup into smaller functions and
add documentation for a couple of non-obvious caveats.