Changed System.out.println occurrences to DebugWriter.write so pulling out random stuff can be easily turned off.