heapq: Import itertools only for functions which really require it.
sqlite3: Less obtrusive debug output.