Split out the where clause to close #545.