Fixed a few JSHint warnings and some minor code changes.