Refactor cleanup, ProviderConfig to backend.
Refactor cleanup and move Keymanager to backend.