ga code, added legends and fixed various issues