  We present general analytic expressions for GRB afterglow light curves
arising from a variable external density profile and/or a variable energy in
the blast wave. The former could arise from a clumpy ISM or a variable stellar
wind; The latter could arise from refreshed shocks or from an angular dependent
jet structure (patchy shell). Both scenarios would lead to a variable light
curve. Our formalism enables us to invert the observed light curve and obtain
possible density or energy profiles. The optical afterglow of GRB 021004 was
detected 537 seconds AB (after the burst) (Fox et al. 2002). Extensive follow
up observations revealed a significant temporal variability. We apply our
formalism to the R-band light curve of GRB 021004 and we find that several
models provide a good fit to the data. We consider the patchy shell model with
$p=2.2$ as the most likely explanation. According to this model our line of
sight was towards a "cold spot" that has lead to a relativity low $\gamma$-ray
flux and an initially weak afterglow (while the X-ray afterglow flux after a
day was above average). Observations above the cooling frequency, $\nu_c$,
could provide the best way to distinguish between our different models.
