Avoid repeatedly querying the list of artefacts

Big performance improvement.