Fixes in memory management and usage of isolates