Move local commands to one place and under an if statement.
Adjust indenting.