Rewrite authentication & event system