correctly handle close case. event queue should be processed
add some debug info
use log facilities correctly
add some debug info