fix encoding of baicker refs
handle near-math-domain-error scaling