more rejiggering to separate c and python implementations