update to work with gs 3.10, lots of bugs corrected and code simplified
comments updated