main: use auto variables where appropriate and sensible