Add cache in evaluation

This patch will speed up the evaluation subroutine a little bit.