Made some fixes to how data is output, including an error object.