Fix possible memory leak, add print statement for basic debuggin.