Multiple fixes to mainFun.R, only remaining issue is updating glist