Fix bugs in vote algorithm.