Complete refactoring. Automated database table creation.