Switched a bunch of print's to logging calls, to avoid buffering.