Use proper indentation (spaces for alignment) in SQL statements
and replace a few ON by USING clauses in JOINs.
No functional changes (intended).