Made scripts more dynamic so they can handle a growing database.