bugfix and export for flushSession()