Refactoring and added events api for prefixes