Changed debug to output to stderr.