Cleanup backend from hacks

* Fix method names.
* Remove unused code.
* Refactor cleanup, ProviderConfig to backend.
* Refactor cleanup and move Keymanager to backend.