Refactor petri generation