Refactored background tasks to separate out exports (in preparation for notification bar version)

Also fixed a window leak after templates are loaded, and ensured that
the import dialog progresses to its maximum