Add matrices to sgp.config and errorhandling for FOREACH