Restructure GA code