Code cleanup (removed unused variables, "local"-ized variables)