More work on porting the Python code.