Fix event redirects and foreign key issues