A small helper function for retrieving ENV vars in a case insensitive way might help clean this up. Something along the lines of:
```
get_env(name)
  ENV[name.downcase] || ENV[name.upcase] || nil
end
```