Fix nested entity flushing