Tweak the bot loop, make variables global, add quit function