Fixing deadlocks in iostreams component