Missed the edit window. Rewrote the bot so the performance is now slightly better, the underlying logic is also easier to understand and reuse for other bots.
http://pastebin.com/hXVsYLXn
http://pastebin.com/hXVsYLXn