Fixed various SQL table naming bugs