fixing some bugs in mysql