Improved database update code to be more efficient.