Fix inconsistencies in using IDs and Reference IDs