fixed memory leak in newton demos