cleanup of scan key building
Bug fix for IS NOT NULL queries