added console.debug and moved debug flag into ENV.
added a utility function to execute a program/query