Cleaned up database recreation logic