Fixed memory leak in not freeing stack and queue