Removed the lambda wrapping the rule script for the target in the thread that the rule executes in. Also added the server as the only argument for the function