polished code in eval.c and apply.c, also export apply to user space