A more flexible main-file logic. Remove the prim/stdlib special cases.