Fix #3117 (by reverting part of a previous change), plus a minor change that might speed GT up.