fixed code according to daniel's comments + moved all static localization out of the db.