And improve labels dialog
Also remove some unnecessary imports
This should speed up synchronization / restoration of large wallets. Wallets are written only when they switch to up_to_date state, or when stop_threads() is called when closing the daemon, or when a command line command finishes.