memory leaks

got rid of mem leaks with auto ptr