Bug fixes and linting