Fixing memory issues in ram