Core/Scripts: fixed memory leak caused by unassigned scripts in db