re #2 rewrote C plugin, now much simpler & shorter.