More electronic functionality

Removed some unused variables.

Tried to add a few more comments to make it easier to understand

added some stuff to make electronic gear work.