Clean up and added additional debug output.
Forgot to turn off debug flag.
Don't set the debug flag within the writeData method.