Extracting the main functionality out of main and into a library