Refactored MySQL support a bit.