Refactored config setup and event generation