Fixed issue with diagram references not being handled correctly