fix #20 again, the logic of remove/addXXXHandlers is not correct
(cherry picked from commit 87cdf4219ed6888b1e55f85563bd8920417c22ce)