fixed potentioal memory leaks