fix bugs and make ESLint happy again