Merge "Fix two bugs in cpu_ref"