Initial code. The *.c code is legacy. The *.py version needs to be completed.