Huge changes!

I started -- and almost finished -- converting all the mysql components to mysqli objects.

A few errors remain, see the issues for details.