Freeing memory in subclassProc function