Adapted Python code to Westpic/solap4py-java@8985cf244b2f3ff531c26bd44d413a295da9436f
+ some cleaning