The effects of thermal annealing on GaInAs/GaAs and GaInAsN/GaAs quantum wells, grown by molecular beam epitaxy, were investigated. Optical and structural properties were examined upon annealing when the samples had a 200 nm thick SiO2 cap layer, or were placed in a so-called GaAs box or were left uncapped. The GaAs box gave rise to the strongest photoluminescence without significant blueshift or structural changes at moderate annealing temperature. Capping with SiO2 impaired the samples and caused a more pronounced blueshift for the GaInAs quantum wells than for the GaInAsN ones. These results consolidate our understanding of the blueshift mechanisms.