added the python script and increase the robustness of the KL methods