Fix the compilation, clean lot of duplicat code