Implements Bash styleguide changes

Google's styleguide encourages:
  - $() over backticks
  - readonly constants at beginning of script
  - Indentation of multiline unix pipes.

Double check that I didn't add any regression, since I can't fully test it locally.