Improvements in main(); more functional decomposition