fix -nw behavior, remove needless codes