Added quoting on variable checks and usage.