Some MySQL fixes

Some optimalization, relations are half integrated (but there probably
is a new table structure soon)