Scabrero/fix memory leaks