Fix bug where a kenv value could be set to NULL