did some refactoring and added missing event registration.