Bug hunt

Lots and lots of stuff.
Started out fixing bugs, and tweaking UI, ended up refactoring lots of Application manager stuff. I tried to separate out commits so they are self documenting.