Fixing bugs revealed by the typed-doppio branch.