Various improvements and fixes for custom events