Patching for Cannot call method 'removeListener' of undefined