moved flush and commit under except for __doxxx() functions as to not thrash the DB