Added $settings var for plugins
Improved error handling for table creation