added some free's
added some free's
added test for core and fixed some memory stuff
mostly fixed memory issues