split RewritingSystem into many smaller files and replaced scala-graph's Graph with own implementation