Bug fixes: resolved a segmentation fault in Redis access if deleted unconnected.

Additionally, several imrovements to avoid memory leaks.