Fixed some bugs that were generating invalid workflows