Added missing SQL update and cleanup