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

Fix invalid memory write caused by calling "delete this;" in a base class constructor.