Changes for adapting the code to the new events library