First pass at separating out datatable part of where clause from rest of...

... it.

Don't look at this yet, I'm just creating the pull request so I can show the changes to Ed, who will probably take over the branch.