Minor performance and code quality improvements.