Changed comparisons to be more straight forward, and quoted all variables (especially those in bash comparisons)