bugfix in unsubscribe function and handling unsubscribes in callbacks