Add Flip matching mode and bug fixes

#define FLIP_MODE
Fixed a bug if equal matching vote happens
Some function structures optimized