major re-write with definitions and many improvements