Environmental and excitonic effects on the first hyperpolarizability of polar molecules and related dimers.