Merge @garyb's core functional AST changes, fixes #710