Utilize MySQLUtil in generator codes
Logic error fixes