Merge upstream

Reproducing the work from @artbristol on the current branch HEAD I split the move to the .local package and the extract of the nested classes in several smaller commits.
I guess if these commits are accepted merging them to the k9 master would reduce merging effort a lot.

Disclaimer:
I'm new on the project. If I've made a mistake, violated project rules or the like please drop me a message so I can learn ;)