preliminary working-well ecm.c
source before a bunch of debug messages are added
almost entirely working