Added better error handling and logging to ScriptComponent.