Fixed a few bugs.

Looks like I forgot to use Object.keys(item).length for object length,
and named the loop variable as if I were using a foreach loop. Chalk it
up to excessive .NET usage/long work hours.