Tweaks to get optimization working.