Pulled in code from AFK.