Fixed some bugs (ie. possible of memory leaks) on Adhoc, and implement a few more Adhoc functions.