Ventilated cavities on a surface-piercing hydrofoil at moderate Froude numbers: cavity formation, elimination and stability