Fix some correctness issues identified by foodcritic