DB script bug fixes