JSHint check and fixed some errors