Renamed $key variable in loops (fixes bug #111155)