Revert "Revert faulty merge"

This reverts commit c9a379b2d9ae9cb1a431e206245a05c7666292b2.

*cough* *cough*
Replace all occurences of "cosm"

While here,
* fix indentation (do not mix tabs and spaces)
* prefix environment variable name with RZL to avoid name conflicts
DRY