Small bug fixes and linting

- Fix undefined variables
- Don’t let Python 3 try and call undefined unicode
- Fix lint warnings