Optimization changes from code review.

Change-Id: Iaf5f85402b974cb52c2fbc36383207622e0392d6
Merge "Optimization changes from code review."