Merge "Fix bug in reference frame counting." into experimental