Minor optimization + logical fix.