Add more mysql debugging and misc tweaks