Removed shared_ptr and fixed event cancellation