Add beginUpdates and endUpdates where necessary