Fixed table name and some bugs