Fix a very subtle bug with closures and local variables that caused selectors not to apply correctly.