fixed possible and actual memory leaks