More simplification in main
Various changes