fixed typo in sample program
removed code that avoids rebuilding the evaluation stack on each iteration
fixed some alloc/free errors detected by a static analysis