small bug fixes to main.m, nothing changed in calc_G.m