minor bug fixes in the build of the output.  The algorithms remain unchanged.