Updated to work with improved reference algorithm