fix a bug in the evaluation, cleanup code