More main program refactorization