Fix exception on empty entry selections during optimize
The earlier fixes to the optimizer in !41 (merged) caused issues with empty entry selection fixed here.
The earlier fixes to the optimizer in !41 (merged) caused issues with empty entry selection fixed here.