Make it truly case-insensitive

The old version just replaced upper-case for lower-case but not vice
versa.