Unregister implementation
Refactoring and adding comments