Moved saving variables to fits header keys closer to finding values