bug fixes in ostrm write. threads are still messed up