better memory management

tried to use most efficient memory possible, especially for global
variables (including passing electrode pairs as a single byte instead
of two ints).

Moved freeMem memory debugging print to it’s own function.