New implementation of flush (WIP)