Moved things out of loops in grav_tess