Rename variables and fix some details