added more optimizations.

Change-Id: I77c524aec436b940c19763b3fe11b82a4eb7e4bd