Cleanup the code handling default application name and configured application name
Since the first delivery of this code (which was a merge of 4 forks), I figured out that a lot of code was duplicated.
The handling of the default application (when no name was configured) was done separatly from the handling of a named application. But the code behind was more or less the same.
This has to be merged.