GA, reordering of code

as above
code cleanup

adding in comments, removing unused variables