Fix session flush handling