When running a batch delete as the "Delete page script" user it overwrites the global $wgUser context. This causes all kinds of errors and pollutes user sessions. The changes fixes this to use the built in functionality to specify the deleting user. I did test for any potential security issues regarding this, but I was unable to create a situation in which two users doing the same action would get their sessions taken over. This also fixes the localized deletebatch-system-username not being used when creating the user.
See the upper right of the screen shot where the logged in user's session was polluted and overwritten with the "Delete page script" user.