Major optimizations

Change-Id: Ieb61e3596f9029e6b27876570f8b51f6294bab90