various changes

e.g. changing debug prints to stderr messages so they don't go out in
stdout