Code cleanup and small fixes (with JSHint).