lib/base/etpm.h,cpp: simplify and cleanup code