[Core] Closed memory leaks and compiler warnings.

A bunch of memory leaks and compiler warnings have been resolved.
We are heading towards a warning free build.

Signed-off-by: Daniel S. Reichenbach <daniel@kogitoapp.com>