Make sure Application.Current exists (it doesn't in unit tests) before trying to use it.
Various small comments.