Don't override 'mode' and cleanup some variable names.