Added more code to patch segments.  Still need code to patch overlapping segments and to write files.