Uses a more reliable string allocation method (hat tip: @wyc)