Formatted code to meet standards and commented. Tables now use LONGTEXT
for JSON strings.