Needed a bit of synchronization on the input/output

If I didn't have this, threads could get out of order, and then stuff
blows up :(