Some minor refactoring and cleaning up related to the opening of files from a plugin.