Minor code enhancements and a typo fix.