5442 added condition around unset(), and added in missing ->keys if(in_array) test for the exsitance of a module