Included optimize function to remove no-live assignments.