gs3.12 fixes
small random fixes
restructured code