ported to upstream Optiq