Fixed bugs in this branch, especially from removing handlers while handling event