Better handling of updating and insertion of location for environment
Merge branch 'location_insert_update_bugfix'