Complete insert and update functions.