bug fixes and clear panels on last script delete