Fixed a bug in scanning optimization.

BUG=
R=adam.sindelar@gmail.com

Review URL: https://codereview.appspot.com/173220043