C/C++ re-engineer and improvement of main PhD algorithm