main: refactor to run defer function. handle non-default -f. handle compiler