I just got my dev environment set back up. This script is my most used one so it's going to be going through a rewrite in the coming weeks.
In the meantime, if you could provide a copy of your log file while the bot is misbehaving, I can look into it and see if there's anything I can do to fix...