library and ScriptEngine cleanup