Refactored creation of tables and fields