Fix two jshint warnings

Two warnings
58	Don't make functions within a loop.
162	The body of a for in should be wrapped in an if statement to filter unwanted properties from the prototype.