Code cleanup and JSHint