Fixed misc mysql code