This is a backport of several bug fixes:
 o Clearer error message for when aggregations are used in ORDER BY and not in RETURN
 o Fixes #390 - IN/ANY/NONE/ANY/SINGLE causes RuntimeException for some patterns
 o Fixes #394 - Identifiers inside of FOREACH get the wrong type