FIX: forgot to reset database on flush errors