Add new optionals hook.

Mulgara seems to break when running with multiple OPTIONAL
statements... Crazy UNIONs to workaround.