Major refactor. Passing tests for (MySQL) export schema.