Move config related code from main.go to config.go

No logic change at all.