fix a polling bug. remove some unused code