Substrate and Mg doping effects in GaAs nanowires