Modularized ET code a bit so the learning code could use it.