Refactored the database generation scripts.