Fix style issues; remove dead code; model cell period selection state as an enum.