Adopting a structure for each function (context,err)
Greatly expanded on configuration.