Clean things up and prepare for MySQL DB output.