performance tune. remove global variable access as much as possible and remove bind().