Reduce the scope of some variables

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>