fixing possible oom bugs