Cosine fixed

Cosine bug fix
Evaluation code improved