Fixed a problem when you call RemoveEvents()

Fixed a problem of the function call RemoveEvents()