Main program modified (a lot)