Refactoring code.

- Moving task logic into existing KeyManager class.
Calling block(s) regardless of success.
Removing unnecessary dependency check.
Removing unnecessary dependency check.
Removing unnecessary object checking.
Privatising methods.