Modified for cavity optimization.