Need to comment. Fixed the memory bugs and all should work. Need to implement the getTargets function