Rework of main, make it clearer