Stability improvements
Fix potential memory leak