Changing the model for events and fixing the connection to the database