quoted (most) variables, added braces around (most) variables, general code cleanup