Fix bug in remove_handler