Bug fixes for evaluation function.