moved debug statements all to stderr