Any reason not to call commit() here?  flush() itself is called as part of the commit() function.