Fixed bugs with variable name mismatches