Lots of changes to support MySQL and stuff