Code edits to make GA work more smoothly. Undefined checks corrected.