How are solar flares related to sunspots?