Moved some stuff around for bug #6597.