Hotfix/memory leak and cleanup