Understanding doping in silicon nanostructures