BAMPFA-113: near-final improvments: better query, error detection, esp. addition of the imageOK flag, a combination of the other flags