Improved code quality with several minor code fixes