Help about arduino and EEPROM

Hi follks,
I need a little help about writing to EEPROM.
Well I wrote a program for remote gsm relay control. And it's working ok but I want to add function to save pin state if a power failure occur. For example if I send "turn on relay 1" and shortly after that there was a power failure, state of the pin must return to previous state.
So I find a little help on this topic but I dont understand this code (I mean I understand but not at all):

// restore the lights
  pins = EEPROM.read(addr);
  for (int i=A0; i<A4; i++) {
    digitalWrite(i, bitRead(pins, i-A0));
  }
// Save the state of the lights
  unsigned char pins = 0;
  for (int i=A0; i<A4; i++) {
   bitWrite(pins, i-A0, digitalRead(i));
   }
   EEPROM.write(addr, pins);

It's ok to read at startup all 4 pins, but in my program I heed to save every pin for itself.
How to save and read one pin at one address?
If I understand correctly I can save all 4 pins in one EEPROM address and read it, but how to save one by one in one EEPROM address?

EEPROM is addressed byte-by-byte, you can only change a byte at a time and you have
to write the whole byte.

But you can read it first and change one bit then write back - not hard to change that
example code:

// Save the state of the lights
void save_pin (byte pin)
{
  unsigned char pins = EEPROM.read (addr) ;
  bitWrite (pins, pin - A0, digitalRead(pin)) ;  assuming A0 is stored in bit 0
  EEPROM.write(addr, pins);

}

So if I understand correctly,
"bitWrite (pins, pin - A0, digitalRead(pin)) ; assuming A0 is stored in bit 0"
Is A0 bit position or what?
What exactly define bit position in bitWrite function?
I use analog ports A0-A3 as digital output for relays.

bitWrite (pins, pin - A0, digitalRead(pin)) ;

bitWrite() takes 3 arguments
The first is the variable to be updated, in this case the pins variable
The second is the bit in the variable to be updated. A0 is an alias for pin 14 so pin - 14 gives us the bit to write to
The third is the value to be written, 0 or 1. Here it is read from the pin using digitalRead()