Fix #537. Incorrect query syntax shouldn't causes internal error
Fix #565. Make sure empty series names don't cause a panic