Massive refactoring of code, fought against DOS to get batch scripts going.
May be a bug with flush(), but not sure what would be causing it.