Connection fixes

Broke MySQL again, but I think I fixed the connection issues introduced
during the last commit.