cleaned up a little, move typecheck code out of eval