fully synchronize and added error checks in GMat, GSMat