rename variables and move some stuff