Bug fixes in insertToDb method of Environment