Confinement effects in crystallization and Er doping of Si nanostructures