cleanups and writebin now blocks until write complete