fixed some memory leaks
fixed tests, added plato