Added possibility of optimizing only (no capture).