Merge with nullquery branch

Various fixes.