Unstable: Last merge for cake_query.erl refactoring

Peter,

This is option two for the final merge of cake_query.erl.

As I said on the previous pull request, I am only 70 % sure it will work because there are redondant commits marked.

If once the previous pull request merge, the commits drop to less or equal to three than it should be ok to merge.

Hopefuly there won't be any more conflicts.

Gary