Fixed bugs and added consistency by quoting variables.