Refactoring views to make activity selection work

I'd recommend reading through this pull request commit by commit and as the first one makes the diff very ugly.