naively added some flushes, barriers to improve output