Renamed some variable names and fixed a problem found