Fixed bugs in evaluate to make it compillable