Change insert to do in place modifications

This should increase performance since the string is getting modified in
place instead of making a new copy.