Remove dead code from ApplicationProvider.cs, minor refactorings