Shorten lines.
Remove trailing space
Use proper bash conditinal variables
Use https for closing instead of ssh, as OAuth tokens are better supported for https