Loop fixes