Fix linter errors and do some code clean up