Caught a memory leak using "pop" and filled out the "free" function.