Structure and role of ultrathin AlN layers for improving optical activation of rare earth implanted GaN