added debug support - query logs in output
remove trailing spaces