Fix wifimanager and manage application  memory leak