Minimal changes to main while implementing all of its functionality in files