Handle case where both default and brew are specified
Fix return code handling
Remove some duplication
Fix some style issues