fixed a segfault in the AQL optimiser