Added setup_guarantee_consistency().
Replaced MALLOC with NEW where possible.

Improves the code because (some variables can be eliminated, some are
const now). Found a few bugs:

* Fixed clause_sf(): literal wasn't added
* Fixed query_subsitute(): in the literal case, the variable l was
  shadowed