Miscellaneous code quality improvements