Fixed a sign and did a little optimization.
Merge branch 'upstream'