Added checking of the this binding to allow the use of function in prototypes as listeners