fixed some mem consumption issues