added event system and logging