Merge latest lemon.c and template from upstream