I have push a refactoring of the JS and the Python code.