patch for bug in optimizing FW queries