Fixed database and script issues