Make extensions case insensitive, and a bit of misc cleanup.