Folding in tmcw changes from the generate script