minor refactoring of top-level mains