Handle equality between fields in WHERE conditions properly
Some refactoring