Fixed event delegation bug with .detach()