fixed mem issues