Fix some loops