Improved where clause reduction.

Signed-off-by: Kevin Stone <kevinastone@gmail.com>