added support for relation directions, reorganized syntax parser