Replaced weird remove/insert code to update.
Fixed compilation