Change "in" with "hasOwnProperty", improve some code.
Remove unused variable.