Used better naming scheme, fixed some memory leaks