indentation cleanup

Use regex for checking if $mode is 'master'.
I was trying to use standalone mode and it wasn't working.
Equivalence never works well for text comparisons.
Plus some indentation cleanup to assist readability.